/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Business;

import java.math.BigInteger;
import java.security.MessageDigest;

/**
 *
 * @author Administrator
 */
public class Encrypt {
    public String encryptMD5(String rawPass) {
        try {
            //Create instane of MessageDigest
            MessageDigest md = MessageDigest.getInstance("MD5");
            //Resets the digest for further use.
            md.reset();
            //Update the digest using the specified ByteBuffer.
            md.update(rawPass.getBytes());
            //The array of bytes for the resulting hash value.
            byte[] digest = md.digest();
            BigInteger bigInt = new BigInteger(1, digest);
            String hashtext = bigInt.toString(16);
            // Now we need to zero pad it to be the full 32 chars.
            while (hashtext.length() < 32) {
                hashtext = "0" + hashtext;
            }
            return hashtext;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }

}
